[turbopack] Use an arena for JSValues#94297
Conversation
Stats skippedCommit: d72a407 |
Failing test suitesCommit: d72a407 | About building and testing Next.js
Expand output● app dir - metadata static routes cache › should generate different content after replace the static metadata file
Expand output● create-next-app with package manager pnpm › should use pnpm for --use-pnpm flag with example ● create-next-app with package manager pnpm › should use pnpm when user-agent is pnpm with example
Expand output● app dir - navigation › hash › should scroll to the specified hash |
a98d014 to
e21492c
Compare
4b5a6ea to
9c87cd9
Compare
| #[derive(Debug)] | ||
| pub enum Effect { | ||
| pub enum Effect<'a> { |
There was a problem hiding this comment.
Follow up: Maybe also make Effect use the arena for everything? Right now it has some global-heap-allocated types.
| }; | ||
|
|
||
| enum EarlyReturn { | ||
| enum EarlyReturn<'a> { |
There was a problem hiding this comment.
Possible future PR: Also use an arena here
9b57fe5 to
b83e7c6
Compare
Bump-allocates the analyzer's `JsValue` tree into a per-thread arena (`ThreadLocal<Bump>`) that lives for the duration of `analyze_ecmascript_module_internal` and is freed in one shot when it returns, replacing the previous `Arc`/`Box`/`Vec` heap allocations. `JsValue` becomes `JsValue<'a>`, with its list children stored in `BumpVec` (growable) or `bumpalo::boxed::Box<[_]>` (fixed) and scalar children in `bumpalo::boxed::Box`. Sync functions take `&Bump` and allocate directly; the async (`Send`-bound) analysis pipeline holds a `&ThreadLocal<Bump>` and obtains a `&Bump` via `get_or_default()`, so no `!Send` `&Bump` is ever held across an `.await`. Builds on the `BumpVec` introduced in the previous commit.
b83e7c6 to
4cc4b5b
Compare
5610ae9 to
916162c
Compare
lukesandberg
left a comment
There was a problem hiding this comment.
it would be useful to describe the thread_local! design in the PR description, how this is solving a problem with async and the associated risks
This PR takes the arena introduced in #94296 and uses it! It's large but shouldn't change functionality beyond the use of the arena. Some syntax related to pattern-matching had to change because
bumpalo'sBoxdoesn't support the same pattern matching that the standard library'sBoxdoes but the code should be equivalent.